package com.isdepci.project.result.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.result.domain.TwoActivity;
import com.isdepci.project.result.service.ITwoActivityService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 范围2分类(按照活动类型划分）Controller
 *
 * @author isdepci
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/result/twoActivity")
public class TwoActivityController extends BaseController
{
    @Autowired
    private ITwoActivityService twoActivityService;

    /**
     * 查询范围2分类(按照活动类型划分）列表
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:list')")
    @GetMapping("/list")
    public TableDataInfo list(TwoActivity twoActivity)
    {
        startPage();
        List<TwoActivity> list = twoActivityService.selectTwoActivityList(twoActivity);
        return getDataTable(list);
    }

    /**
     * 导出范围2分类(按照活动类型划分）列表
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:export')")
    @Log(title = "范围2分类(按照活动类型划分）", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TwoActivity twoActivity)
    {
        List<TwoActivity> list = twoActivityService.selectTwoActivityList(twoActivity);
        ExcelUtil<TwoActivity> util = new ExcelUtil<TwoActivity>(TwoActivity.class);
        return util.exportExcel(list, "twoActivity");
    }

    /**
     * 获取范围2分类(按照活动类型划分）详细信息
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(twoActivityService.selectTwoActivityById(id));
    }

    /**
     * 新增范围2分类(按照活动类型划分）
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:add')")
    @Log(title = "范围2分类(按照活动类型划分）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TwoActivity twoActivity)
    {
        return toAjax(twoActivityService.insertTwoActivity(twoActivity));
    }

    /**
     * 修改范围2分类(按照活动类型划分）
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:edit')")
    @Log(title = "范围2分类(按照活动类型划分）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TwoActivity twoActivity)
    {
        return toAjax(twoActivityService.updateTwoActivity(twoActivity));
    }

    /**
     * 删除范围2分类(按照活动类型划分）
     */
    @PreAuthorize("@ss.hasPermi('result:twoActivity:remove')")
    @Log(title = "范围2分类(按照活动类型划分）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(twoActivityService.deleteTwoActivityByIds(ids));
    }
}
